using System;
using System.Globalization;
using System.IO;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Newtonsoft.Json.Converters;
using ns20;

namespace Newtonsoft.Json
{
	public static class JsonConvert
	{
		[CompilerGenerated]
		private sealed class Class109
		{
			public object object_0;

			public Formatting formatting_0;

			public JsonSerializerSettings jsonSerializerSettings_0;

			public string method_0()
			{
				return SerializeObject(object_0, formatting_0, jsonSerializerSettings_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class110<T>
		{
			public string string_0;

			public JsonSerializerSettings jsonSerializerSettings_0;

			public T method_0()
			{
				return DeserializeObject<T>(string_0, jsonSerializerSettings_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class111
		{
			public string string_0;

			public Type type_0;

			public JsonSerializerSettings jsonSerializerSettings_0;

			public object method_0()
			{
				return DeserializeObject(string_0, type_0, jsonSerializerSettings_0);
			}
		}

		[CompilerGenerated]
		private sealed class Class112
		{
			public string string_0;

			public object object_0;

			public JsonSerializerSettings jsonSerializerSettings_0;

			public void method_0()
			{
				PopulateObject(string_0, object_0, jsonSerializerSettings_0);
			}
		}

		public static readonly string True = "true";

		public static readonly string False = "false";

		public static readonly string Null = "null";

		public static readonly string Undefined = "undefined";

		public static readonly string PositiveInfinity = "Infinity";

		public static readonly string NegativeInfinity = "-Infinity";

		public static readonly string NaN = "NaN";

		[CompilerGenerated]
		private static Func<JsonSerializerSettings> func_0;

		public static Func<JsonSerializerSettings> DefaultSettings
		{
			[CompilerGenerated]
			get
			{
				return func_0;
			}
			[CompilerGenerated]
			set
			{
				func_0 = value;
			}
		}

		public static string ToString(DateTime value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind);
		}

		public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
		{
			DateTime dateTime_ = Class185.smethod_2(value, timeZoneHandling);
			using StringWriter stringWriter = Class199.smethod_6(64);
			stringWriter.Write('"');
			Class185.smethod_16(stringWriter, dateTime_, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(DateTimeOffset value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat);
		}

		public static string ToString(DateTimeOffset value, DateFormatHandling format)
		{
			using StringWriter stringWriter = Class199.smethod_6(64);
			stringWriter.Write('"');
			Class185.smethod_21(stringWriter, value, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(bool value)
		{
			if (!value)
			{
				return False;
			}
			return True;
		}

		public static string ToString(char value)
		{
			return ToString(char.ToString(value));
		}

		public static string ToString(Enum value)
		{
			return value.ToString("D");
		}

		public static string ToString(int value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(short value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ushort value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(uint value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(long value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		private static string smethod_0(BigInteger bigInteger_0)
		{
			return bigInteger_0.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ulong value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(float value)
		{
			return smethod_4(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string smethod_1(float float_0, FloatFormatHandling floatFormatHandling_0, char char_0, bool bool_0)
		{
			return smethod_2(float_0, smethod_4(float_0, float_0.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling_0, char_0, bool_0);
		}

		private static string smethod_2(double double_0, string string_0, FloatFormatHandling floatFormatHandling_0, char char_0, bool bool_0)
		{
			if (floatFormatHandling_0 != FloatFormatHandling.Symbol && (double.IsInfinity(double_0) || double.IsNaN(double_0)))
			{
				if (floatFormatHandling_0 == FloatFormatHandling.DefaultValue)
				{
					if (bool_0)
					{
						return Null;
					}
					return "0.0";
				}
				return char_0 + string_0 + char_0;
			}
			return string_0;
		}

		public static string ToString(double value)
		{
			return smethod_4(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string smethod_3(double double_0, FloatFormatHandling floatFormatHandling_0, char char_0, bool bool_0)
		{
			return smethod_2(double_0, smethod_4(double_0, double_0.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling_0, char_0, bool_0);
		}

		private static string smethod_4(double double_0, string string_0)
		{
			if (!double.IsNaN(double_0) && !double.IsInfinity(double_0) && string_0.IndexOf('.') == -1 && string_0.IndexOf('E') == -1 && string_0.IndexOf('e') == -1)
			{
				return string_0 + ".0";
			}
			return string_0;
		}

		private static string smethod_5(string string_0)
		{
			if (string_0.IndexOf('.') != -1)
			{
				return string_0;
			}
			return string_0 + ".0";
		}

		public static string ToString(byte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(sbyte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(decimal value)
		{
			return smethod_5(value.ToString(null, CultureInfo.InvariantCulture));
		}

		public static string ToString(Guid value)
		{
			return smethod_6(value, '"');
		}

		internal static string smethod_6(Guid guid_0, char char_0)
		{
			string text = null;
			text = guid_0.ToString("D", CultureInfo.InvariantCulture);
			return char_0 + text + char_0;
		}

		public static string ToString(TimeSpan value)
		{
			return smethod_7(value, '"');
		}

		internal static string smethod_7(TimeSpan timeSpan_0, char char_0)
		{
			return ToString(timeSpan_0.ToString(), char_0);
		}

		public static string ToString(Uri value)
		{
			if (value == null)
			{
				return Null;
			}
			return smethod_8(value, '"');
		}

		internal static string smethod_8(Uri uri_0, char char_0)
		{
			return ToString(uri_0.ToString(), char_0);
		}

		public static string ToString(string value)
		{
			return ToString(value, '"');
		}

		public static string ToString(string value, char delimiter)
		{
			if (delimiter != '"' && delimiter != '\'')
			{
				throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
			}
			return Class190.smethod_1(value, delimiter, bool_3: true);
		}

		public static string ToString(object value)
		{
			if (value == null)
			{
				return Null;
			}
			return Class182.smethod_1(value) switch
			{
				Enum17.Char => ToString((char)value), 
				Enum17.Boolean => ToString((bool)value), 
				Enum17.SByte => ToString((sbyte)value), 
				Enum17.Int16 => ToString((short)value), 
				Enum17.UInt16 => ToString((ushort)value), 
				Enum17.Int32 => ToString((int)value), 
				Enum17.Byte => ToString((byte)value), 
				Enum17.UInt32 => ToString((uint)value), 
				Enum17.Int64 => ToString((long)value), 
				Enum17.UInt64 => ToString((ulong)value), 
				Enum17.Single => ToString((float)value), 
				Enum17.Double => ToString((double)value), 
				Enum17.DateTime => ToString((DateTime)value), 
				Enum17.DateTimeOffset => ToString((DateTimeOffset)value), 
				Enum17.Decimal => ToString((decimal)value), 
				Enum17.Guid => ToString((Guid)value), 
				Enum17.TimeSpan => ToString((TimeSpan)value), 
				Enum17.BigInteger => smethod_0((BigInteger)value), 
				Enum17.Uri => ToString((Uri)value), 
				Enum17.String => ToString((string)value), 
				Enum17.DBNull => Null, 
				_ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".smethod_0(CultureInfo.InvariantCulture, value.GetType())), 
			};
		}

		public static string SerializeObject(object value)
		{
			return SerializeObject(value, Formatting.None, (JsonSerializerSettings)null);
		}

		public static string SerializeObject(object value, Formatting formatting)
		{
			return SerializeObject(value, formatting, (JsonSerializerSettings)null);
		}

		public static string SerializeObject(object value, params JsonConverter[] converters)
		{
			return SerializeObject(value, Formatting.None, converters);
		}

		public static string SerializeObject(object value, Formatting formatting, params JsonConverter[] converters)
		{
			object obj;
			if (converters != null && converters.Length > 0)
			{
				JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
				jsonSerializerSettings.Converters = converters;
				obj = jsonSerializerSettings;
			}
			else
			{
				obj = null;
			}
			JsonSerializerSettings settings = (JsonSerializerSettings)obj;
			return SerializeObject(value, formatting, settings);
		}

		public static string SerializeObject(object value, JsonSerializerSettings settings)
		{
			return SerializeObject(value, Formatting.None, settings);
		}

		public static string SerializeObject(object value, Formatting formatting, JsonSerializerSettings settings)
		{
			return SerializeObject(value, null, formatting, settings);
		}

		public static string SerializeObject(object value, Type type, Formatting formatting, JsonSerializerSettings settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			StringBuilder sb = new StringBuilder(256);
			StringWriter stringWriter = new StringWriter(sb, CultureInfo.InvariantCulture);
			using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter))
			{
				jsonTextWriter.Formatting = formatting;
				jsonSerializer.Serialize(jsonTextWriter, value, type);
			}
			return stringWriter.ToString();
		}

		public static Task<string> SerializeObjectAsync(object value)
		{
			return SerializeObjectAsync(value, Formatting.None, null);
		}

		public static Task<string> SerializeObjectAsync(object value, Formatting formatting)
		{
			return SerializeObjectAsync(value, formatting, null);
		}

		public static Task<string> SerializeObjectAsync(object value, Formatting formatting, JsonSerializerSettings settings)
		{
			return Task.Factory.StartNew(() => SerializeObject(value, formatting, settings));
		}

		public static object DeserializeObject(string value)
		{
			return DeserializeObject(value, (Type)null, (JsonSerializerSettings)null);
		}

		public static object DeserializeObject(string value, JsonSerializerSettings settings)
		{
			return DeserializeObject(value, null, settings);
		}

		public static object DeserializeObject(string value, Type type)
		{
			return DeserializeObject(value, type, (JsonSerializerSettings)null);
		}

		public static T DeserializeObject<T>(string value)
		{
			return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings)null);
		}

		public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
		{
			return DeserializeObject<T>(value);
		}

		public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
		{
			return DeserializeObject<T>(value, settings);
		}

		public static T DeserializeObject<T>(string value, params JsonConverter[] converters)
		{
			return (T)DeserializeObject(value, typeof(T), converters);
		}

		public static T DeserializeObject<T>(string value, JsonSerializerSettings settings)
		{
			return (T)DeserializeObject(value, typeof(T), settings);
		}

		public static object DeserializeObject(string value, Type type, params JsonConverter[] converters)
		{
			object obj;
			if (converters != null && converters.Length > 0)
			{
				JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
				jsonSerializerSettings.Converters = converters;
				obj = jsonSerializerSettings;
			}
			else
			{
				obj = null;
			}
			JsonSerializerSettings settings = (JsonSerializerSettings)obj;
			return DeserializeObject(value, type, settings);
		}

		public static object DeserializeObject(string value, Type type, JsonSerializerSettings settings)
		{
			Class204.smethod_2(value, "value");
			StringReader reader = new StringReader(value);
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			if (!jsonSerializer.method_0())
			{
				jsonSerializer.Boolean_0 = true;
			}
			return jsonSerializer.Deserialize(new JsonTextReader(reader), type);
		}

		public static Task<T> DeserializeObjectAsync<T>(string value)
		{
			return DeserializeObjectAsync<T>(value, null);
		}

		public static Task<T> DeserializeObjectAsync<T>(string value, JsonSerializerSettings settings)
		{
			return Task.Factory.StartNew(() => DeserializeObject<T>(value, settings));
		}

		public static Task<object> DeserializeObjectAsync(string value)
		{
			return DeserializeObjectAsync(value, null, null);
		}

		public static Task<object> DeserializeObjectAsync(string value, Type type, JsonSerializerSettings settings)
		{
			return Task.Factory.StartNew(() => DeserializeObject(value, type, settings));
		}

		public static void PopulateObject(string value, object target)
		{
			PopulateObject(value, target, null);
		}

		public static void PopulateObject(string value, object target, JsonSerializerSettings settings)
		{
			StringReader reader = new StringReader(value);
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			using JsonReader jsonReader = new JsonTextReader(reader);
			jsonSerializer.Populate(jsonReader, target);
			if (jsonReader.Read() && jsonReader.JsonToken_0 != JsonToken.Comment)
			{
				throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object.");
			}
		}

		public static Task PopulateObjectAsync(string value, object target, JsonSerializerSettings settings)
		{
			return Task.Factory.StartNew(delegate
			{
				PopulateObject(value, target, settings);
			});
		}

		public static string SerializeXmlNode(XmlNode node)
		{
			return SerializeXmlNode(node, Formatting.None);
		}

		public static string SerializeXmlNode(XmlNode node, Formatting formatting)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static string SerializeXmlNode(XmlNode node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.OmitRootObject = omitRootObject;
			XmlNodeConverter xmlNodeConverter2 = xmlNodeConverter;
			return SerializeObject(node, formatting, xmlNodeConverter2);
		}

		public static XmlDocument DeserializeXmlNode(string value)
		{
			return DeserializeXmlNode(value, null);
		}

		public static XmlDocument DeserializeXmlNode(string value, string deserializeRootElementName)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XmlDocument DeserializeXmlNode(string value, string deserializeRootElementName, bool writeArrayAttribute)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter);
		}

		public static string SerializeXNode(XObject node)
		{
			return SerializeXNode(node, Formatting.None);
		}

		public static string SerializeXNode(XObject node, Formatting formatting)
		{
			return SerializeXNode(node, formatting, omitRootObject: false);
		}

		public static string SerializeXNode(XObject node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.OmitRootObject = omitRootObject;
			XmlNodeConverter xmlNodeConverter2 = xmlNodeConverter;
			return SerializeObject(node, formatting, xmlNodeConverter2);
		}

		public static XDocument DeserializeXNode(string value)
		{
			return DeserializeXNode(value, null);
		}

		public static XDocument DeserializeXNode(string value, string deserializeRootElementName)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XDocument DeserializeXNode(string value, string deserializeRootElementName, bool writeArrayAttribute)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter);
		}
	}
}
